package Command;

import Server.Command;
import Server.cmdArguments;

public class TotalCommand implements Command {
	private cmdArguments args;
	
	public TotalCommand(){};
	
	@Override
	public String execute() {
		String result = "Command not allowed without the database.";
		if (args.db) {
//			Integer sum = 0;			
//			for (Integer i : args.ds) {
//				sum += i;
//			}	
			Integer total = args.bst.getTotal();
			
//			result= "There are a total of " + args.ds.size() + " entries in your data set." + " Add them all together and you get: " + sum + ".";
			result= "There are a total of " + args.bst.getSize() + " entries in your data set." + " Add them all together and you get: " + total + ".";
		}
		return result;
	}
	
	@Override
	public String undo() {
		return "Undo on a print function is not possible. Try again for the previous command.";
	}
	
	@Override
	public void setArgs(cmdArguments args) {
		this.args=args;
	}
}
